﻿using BDShop.Configuration;
using BDShop.Entities;
using BDShop.Framework;
using BDShop.Framework.Caching;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BDShop.Business.Cache
{
    public class SupplierCache: BaseCache<List<Supplier>>
    {
        public SupplierCache()
            : base(BDShopConfiguration.Cache.CacheSupplier, SupplierService.GetListSupplierCacheModel, true, CacheManager.GetFilePathFO(CacheEnum.supplier))
        {

        }

        public static SupplierCache Instance
        {
            get
            {
                return SingletonBase<SupplierCache>.Instance;
            }
        }

        public static Supplier GetByID(int supID)
        {
            //Get supplier from cache
            return SupplierCache.Instance.Get().Where(s=>s.ID==supID).FirstOrDefault();            
        }
    }
}
